//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Text.RegularExpressions;
using System.Web;

namespace CommunityServer.Components
{
	/// <summary>
	/// Summary description for UrlReWriteProvider.
	/// </summary>
	public abstract class UrlReWriteProvider
	{

        static readonly UrlReWriteProvider _instance;

        static UrlReWriteProvider()
        {
            Type defaultProviderType = null;

			if (Environment.Version.Major >= 2)
            {
                defaultProviderType = Type.GetType("CommunityServer.Components.CSASPNET20UrlReWriteProvider, CommunityServer.Components");
            }

            if(defaultProviderType == null)
                defaultProviderType = typeof(CSUrlReWriter); 

            _instance = SingletonProviderHelper.LoadInstance("UrlReWriteProvider", defaultProviderType) as UrlReWriteProvider;
        }

        public static UrlReWriteProvider Instance()
        {
            if(_instance == null)
                CatastrophicMessage.Write(HttpContext.Current, new CSException(CSExceptionType.UnknownError, "UrlReWriteProvider could not be loaded"),"[UrlReWriteProvider]","UrlReWriteProvider.htm");
            
            return _instance;
           
        }

        public abstract string GetRewrittenUrl(string path, string queryString);

        public abstract void RewriteUrl(HttpContext context, string path, string queryString);
	}

}
